package Array;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by joel on 2018/7/4.
 * 我们把符合下列属性的数组 A 称作山脉：

 A.length >= 3
 存在 0 < i < A.length - 1 使得A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1]
 给定一个确定为山脉的数组，返回任何满足 A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1] 的 i 的值。



 示例 1：

 输入：[0,1,0]
 输出：1
 示例 2：

 输入：[0,2,1,0]
 输出：1


 提示：

 3 <= A.length <= 10000
 0 <= A[i] <= 10^6
 A 是如上定义的山脉
 */
 class PeakIndexInAMountainArray {
    public int peakIndexInMountainArray(int[] A) {
        int flag = 0;
        for(int i = 0; i< A.length; i++) {
            if(A[i]>A[i+1]){
                flag = i;
                return flag;
            }
            else continue;
        }
        return flag;
    }

}
class PeakMainClass {
    public static int[] stringToIntegerArray(String input) {
        input = input.trim();
        input = input.substring(1, input.length() - 1);
        if (input.length() == 0) {
            return new int[0];
        }

        String[] parts = input.split(",");
        int[] output = new int[parts.length];
        for(int index = 0; index < parts.length; index++) {
            String part = parts[index].trim();
            output[index] = Integer.parseInt(part);
        }
        return output;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = in.readLine()) != null) {
            int[] A = stringToIntegerArray(line);

            int ret = new PeakIndexInAMountainArray().peakIndexInMountainArray(A);

            String out = String.valueOf(ret);

            System.out.print(out);
        }
    }
}

